#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3f;

void solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int mi = 1e18;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] < mi) mi = a[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) if (a[i] == mi) cnt++;
    int ans;
    if (cnt >= 2) ans = mi * (2 * (n - 1));
    else
    {
        int sum = 0;
        for (int i = 0; i < n; i++) sum += a[i];
        ans = sum + mi * (n - 2);
    }
    cout << ans << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--)
    {
        solve();
    }
    return 0;
}